#setwd("~/Dropbox/AWS Infrastructure")
setwd("./Downloads/readme-software")
{ 
try(unlink("readme", recursive = T), T) 
try(file.remove("./readme.pdf"), T)  
try(file.remove("./readme.tar.gz"), T)  
  
aut1 = person(given = "Gary",family="King", email = "king@harvard.edu", role  = c("aut"))
aut2 = person(given = "Anton", family="Strezhnev", email = "a.strezhnev@gmail.com", role  = c("aut"))
aut3 = person(given = "Connor", family="Jerzak", email = "cjerzak@g.harvard.edu", role  = c("aut", "cre"))
authors_at_r <- paste0("'", aut1,", ", aut2, ", ", aut3, "'")
options(devtools.desc.author=authors_at_r)
  
my_description <- list( 
  "Title" = "An Algorithm for Text Quantification", 
  "Authors@R" = authors_at_r,
  "Version" = "2.0",
  "Maintainer" = "'Connor Jerzak' <cjerzak@g.harvard.edu>",
  "Description" = "An R package for estimating category proportions in an unlabeled set of documents by implementing the method described in Jerzak, King, and Strezhnev (2018). This method is meant to improve on the ideas in Hopkins and King (2010), which introduced a quantification algorithm that harnesses the Law of Total Expectation. We apply this law in a feature space that is now crafted to minimize the error of the resulting estimate. Automatic differentiation, stochastic gradient descent, and batch re-normalization are used to carry out the optimization. Other pre-processing functions are available, as well as an interface to the earlier version of the algorithm.",
  "License" = "Creative Commons Attribution-Noncommercial-No Derivative Works 4.0, for academic use only.",
  "Depends" = "tensorflow, tokenizers, optmatch"
)

#devtools::create("./readme", my_description)

#after loading in correct files to ./Readme2/R/ folder 
core_files <- list.files("./Readme2_CoreCode/")
core_files <- sprintf('./Readme2_CoreCode/%s',core_files)
file.copy(from=core_files, to="./readme/R/", overwrite = TRUE, recursive = FALSE, copy.mode = TRUE)
roxygen2::roxygenise("./readme/")
devtools::document(pkg = "./readme/")

#in terminal: 
devtools::document("./readme/")
system("R CMD Rd2pdf readme")
}

devtools::document("./readme/")
system("R CMD Rd2pdf readme")
